function thisrender(this, hFig, pos)
%RENDER Render the varsinheader object
%   RENDER(this, hFIG, POS) Render the varsinheader object (this) to the
%   figure hFIG in the position POS.

%   Author(s): J. Schickler
%   Copyright 1988-2004 The MathWorks, Inc.
%   $Revision: 1.3.4.4 $  $Date: 2004/12/26 22:22:22 $

if nargin < 3
    pos = [10 10 300 200];
    if nargin < 2
        hFig = gcf;
    end
end

sz  = gui_sizes(this);
cbs = callbacks(this);

hPanel = uipanel('Parent', hFig, ...
    'Visible',  'Off', ...
    'Units',    'Pixels', ...
    'Position', pos, ...
    'Units',    'Normalized', ...
    'tag',      'exportheader_variableframe', ...
    'Title',    'Variable names in C header file');

hLayout = siglayout.gridbaglayout(hPanel);

set(hLayout, ...
    'HorizontalGap',     5, ...
    'VerticalGap',       5, ...
    'HorizontalWeights', [0 1 0 1], ...
    'VerticalWeights',   [0 1]);

for i = 1:2

    if i == 1
        ti = 20*sz.pixf;
    else
        ti = 5*sz.pixf;
    end

    % Render the controls
    num = num2str(i);

    h.label(i) = uicontrol(hFig, ...
        'Style', 'Text', ...
        'HorizontalAlignment', 'Left', ...
        'String', 'Test', ...
        'Tag', ['varsinheader_lbl' num]);

    h.varedit(i) = uicontrol(hFig, ...
        'Style', 'Edit', ...
        'HorizontalAlignment', 'Left', ...
        'String', 'Test', ...
        'UserData', i, ...  % Callback needs to know the index
        'Callback', {cbs.name, this}, ...
        'tag', ['varsinheader_edit' num]);

    h.length(i) = uicontrol(hFig, ...
        'Style', 'Text', ...
        'tag', ['varsinheader_lengthlbl' num], ...
        'HorizontalAlignment', 'Left', ...
        'String', 'Test');

    h.lengthedit(i) = uicontrol(hFig, ...
        'Style', 'Edit', ...
        'tag', ['varsinheader_length' num], ...
        'UserData', i, ...
        'HorizontalAlignment', 'Left', ...
        'String', 'Test', ...
        'Callback', {cbs.length, this});

    hLayout.add(h.label(i), i, 1, ...
        'MinimumHeight', sz.uh-sz.lblTweak, ...
        'TopInset',      ti, ...
        'LeftInset',     5*sz.pixf, ...
        'Anchor',        'NorthWest');

    hLayout.add(h.varedit(i), i, 2, ...
        'MinimumHeight', sz.uh, ...
        'MinimumWidth',  0, ...
        'TopInset',      ti, ...
        'Fill',          'Horizontal', ...
        'Anchor',        'NorthWest');

    hLayout.add(h.length(i), i, 3, ...
        'MinimumHeight', sz.uh-sz.lblTweak, ...
        'TopInset',      ti, ...
        'LeftInset',     5*sz.pixf, ...
        'Anchor',        'NorthWest');

    hLayout.add(h.lengthedit(i), i, 4, ...
        'MinimumHeight', sz.uh, ...
        'MinimumWidth',  0, ...
        'TopInset',      ti, ...
        'RightInset',    5*sz.pixf, ...
        'Anchor',        'NorthWest', ...
        'Fill',          'Horizontal');
end

set(this, 'Handles', h, 'Parent', hFig, 'Container', hPanel, 'Layout', hLayout);

% Sync the GUI with the settings
enable_listener(this);
update_editboxes(this);

listen = [ ...
    handle.listener(this, this.findprop('CurrentStructure'), ...
    'PropertyPostSet', @currentstructure_listener); ...
    handle.listener(this, this.findprop('VariableNames'), ...
    'PropertyPostSet', @variablenames_listener); ...
    ];

set(listen, 'CallbackTarget', this);

set(this, 'WhenRenderedListeners', listen);

% [EOF]
